package band.wukong.practice.java.pattern.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Desc: 动态代理的例子
 * Author: sunjs
 * Date: 2009-12-9 10:39:45
 */
public class DynamicProxyHandler implements InvocationHandler {
    private Object proxied;

    public DynamicProxyHandler(Object proxied) {
        super();
        this.proxied = proxied;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("proxy.getClass() = " + proxy.getClass());
        System.out.println("method = " + method);
        if(null != args)
        for(Object arg : args)
            System.out.println("arg = " + arg);
        return method.invoke(proxied, args);
    }
}
